/*
 * Copyright 2018-10-14 21:39:18 The JA-SIG Collaborative. All rights reserved.
 * distributed with thi file and available online at
 */
package com.lap.scp.erp.core.impl;

import java.util.Collections;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lap.scd.commons.core.exception.ManagerException;
import com.lap.scd.commons.page.Page;
import com.lap.scp.erp.core.MaterielManager;
import com.lap.scp.erp.dal.MaterielDAO;
import com.lap.scp.erp.domain.MaterielDO;
import com.lap.scp.erp.query.MaterielQueryVO;

/**
 * <pre>
 * 物料基本信息维护业务代码默认实现类，这里提供最小元素原子操作，所以尽量少在该类中做流程代码。
 * 业务流程代码应该写在AO中。
 * </pre>
 * 
 * @author 劳水生 Exp
 * @Date 2018-10-14 21:39:18
 * @since 2.0.0
 */
@Service("materielManager")
public class DefaultMaterielManager implements MaterielManager {
	/**
	 *物料基本信息维护数据操作对象
	 */
	@Resource
	private MaterielDAO materielDAO;

	@Override
	public void insertMateriel(MaterielDO materielDO) throws ManagerException {
		materielDAO.insertMateriel(materielDO);
	}

	@Override
	public int deleteById(Integer materielId) throws ManagerException {
		return materielDAO.deleteById(materielId);
	}

	@Override
	public MaterielDO queryById(Integer materielId) throws ManagerException {
		return materielDAO.queryById(materielId);
	}

	@Override
	public List<MaterielDO> queryPage(Page page, MaterielQueryVO queryVO) throws ManagerException {
		int count = materielDAO.countPage(queryVO);
		if (count == 0) {
			return Collections.emptyList();
		} else {
			page.setTotalItem(count);
			return materielDAO.queryPage(page, queryVO);
		}
	}

	@Override
	public int updateMateriel(MaterielDO materielDO) throws ManagerException {
		return materielDAO.updateMateriel(materielDO);
	}

}
